package com.hxd.otc.module.my.presenter;

import com.app.hubert.guide.util.LogUtil;
import com.hxd.otc.R;
import com.hxd.otc.module.my.contract.WebViewContract;
import com.hxd.otc.module.my.model.UserModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.HttpFileObserver;
import com.hxd.otc.utils.LogUtils;
import com.hxd.otc.utils.UIUtils;

import okhttp3.ResponseBody;

/**
 * 包  名 :  com.example.administrator.blocksbankclient.mvp.order
 * 类  名 :  OrderPresenter
 * 作  者 :  zjl
 * 时  间 :  2018/6/4 17:02
 * 描  述 :  ${TODO}所有订单页面P
 */
public class WebViewPresenter extends BasePresenter<WebViewContract.View> implements WebViewContract.Presenter {

    private final UserModel userModel;

    public WebViewPresenter(WebViewContract.View view) {
        super(view);
        userModel = UserModel.getInstance();
    }

    @Override
    public void start() {
    }


    @Override
    public void downloadFile(String downloadUrl,String fileName) {
        userModel.downLoadFile(downloadUrl,fileName, new HttpFileObserver() {
            @Override
            public void onNext(boolean isFileSaveSuccess) {
                if (isFileSaveSuccess) {
                    mView.downloadFileSuccess();
                } else {
                    mView.onError(0);
                }
            }

            @Override
            public void onError(int errType, String errMessage) {
                mView.onError(errType);
                mView.showToast(errMessage);
            }
        }, mView.<ResponseBody>bindAutoDispose());
    }
}
